package testcase.app;

import org.json.JSONObject;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import api.app.FamousDoctorForm;
import common.Host;
import common.TestData;
/**
 * 帮忙医获取约名医订单信息FamousDoctorForm接口测试用例
 * @author lipeng
 */
public class TestFamousDoctorForm {
	/**
	 * 帮忙医获取约名医订单信息FamousDoctorForm接口测试环境数据驱动
	 * @return
	 * @throws Exception
	 */
   @DataProvider(name = "Test")
   public static String[][] testFamousDoctorFormDataProvider() throws Exception{
	   Host.setup("Test");
	   TestData td = new TestData("app/TestFamousDoctorForm.xml");
	   return td.getParam();
   }
   
     /**
	   * 帮忙医获取约名医订单信息FamousDoctorForm接口
	   * @param casename   用例名称
	   * @param token      
	   * @throws Exception
	   */
   @Test(dataProvider="Test",groups={"Test"})
   public void testFamousDoctorFormTestCase(String caseName,String token)throws Exception{
	   //调用接口并将接口返回数据转换成json格式
	   String result = FamousDoctorForm.get(token);
	   
	   JSONObject jsonResult;
	   if(result==null ||result.isEmpty()){
		   jsonResult=null;
	   }
	   else {
		jsonResult= new JSONObject(result);
	   }
	  //设置检查点
	   switch (caseName) {
	     case "Success":
		       Assert.assertEquals(jsonResult.getString("Data").isEmpty(),false);
		       break;
       default:
		       break;
	}
   }
   
}
